backport failsafe changes from kamikaze - the whiterussian implementation failed...
authorFelix Fietkau <[email protected]>
Sat, 3 Feb 2007 10:53:58 +0000 (10:53 +0000)
committerFelix Fietkau <[email protected]>
Sat, 3 Feb 2007 10:53:58 +0000 (10:53 +0000)
SVN-Revision: 6254

openwrt/package/base-files/default/etc/preinit
openwrt/package/base-files/default/sbin/hotplug.failsafe

index 5b315927b3d7c7c2de22e0a059b82e5c460a3865..3f94442c672e4cdcbd3f16d2886e42fbefa58760 100755 (executable)
@@ -1,20 +1,47 @@
 #!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
 . /etc/functions.sh
 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 
+failsafe() {
+       lock /tmp/.failsafe
+
+       echo "0 1 2 3 4 5u*" > /proc/switch/eth0/vlan/0/ports
+       
+       set_state failsafe
+       [ -x "/usr/sbin/nvram" ] && {
+               [ "$(nvram get boot_wait)" != "on" ] && {
+                       nvram set boot_wait=on
+                       nvram commit
+               }
+       }
+
+       netmsg 192.168.1.255 "Entering Failsafe!"
+       telnetd -l /bin/login <> /dev/null 2>&1
+
+       ash --login
+}
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 mount none /proc -t proc
 size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
 mount none /tmp -t tmpfs -o size=$size
 
 insmod diag
-echo /sbin/hotplug.failsafe > /proc/sys/kernel/hotplug
 set_state preinit
+trap 'FAILSAFE=true' USR1
+echo '/sbin/hotplug.failsafe' > /proc/sys/kernel/hotplug
 
 ifname=eth0
-# WAP54G, WL-HDD
-[  "$(nvram get boardnum)" = "2" \
--o \( "$(nvram get boardnum)" = "asusX" \
-   -a "$(($(nvram get et1phyaddr)))" -eq 1 \) ] && ifname="eth1"
+
+# hardware specific overrides
+case "$(cat /proc/diag/model)" in
+       "Linksys WAP54G V1") ifname=eth1;;
+       "ASUS WL-HDD") ifname=eth1;;
+       "ASUS WL-300g") ifname=eth1;;
+       "ASUS (unknown, BCM4702)") ifname=eth1;;
+esac
 
 insmod switch-core
 insmod switch-robo || insmod switch-adm || rmmod switch-core
@@ -41,7 +68,10 @@ ifconfig $ifname 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255 up
 
 sleep 2
 
+eval ${FAILSAFE:+failsafe}
+
 lock -w /tmp/.failsafe
+set_state preinit
 echo /sbin/hotplug > /proc/sys/kernel/hotplug
 
 ifconfig $ifname 0.0.0.0 down
@@ -56,5 +86,4 @@ ifconfig $ifname 0.0.0.0 down
 }
 
 mount_root
-
 exec /sbin/init
index 8a3cb9b7fb384e432859c3493c6627d37ef72203..0544339de89f5679f950c2d2d382600528ed3c1b 100755 (executable)
@@ -1,24 +1,4 @@
 #!/bin/sh
-[ "$1" = "button" -a "$ACTION" = "pressed" ] && {
-       echo /bin/true > /proc/sys/kernel/hotplug
-       lock /tmp/.failsafe
-
-       case "$(nvram get boardtype)" in
-               0x0467|0x042f) echo "0 1 2 3 5u*";;
-                           *) echo "1 2 3 4 5u*";;
-       esac > /proc/switch/eth0/vlan/0/ports
-
-       . /etc/functions.sh
-       set_state failsafe
-       [ "$(nvram get boot_wait)" != "on" ] && {
-               nvram set boot_wait=on
-               nvram commit
-       }
-
-       netmsg 192.168.1.255 "Entering Failsafe!"
-       telnetd -l /bin/login <> /dev/null 2>&1
-
-       exec </dev/console >/dev/console 2>/dev/console
-       ash --login
-       lock -u /tmp/.failsafe
-}
+case "$1" in
+       button) kill -USR1 1;;
+esac